package com.nbsaas.boot.solution.rest.convert;

import com.nbsaas.boot.solution.data.entity.SolutionCatalog;
import com.nbsaas.boot.solution.api.domain.request.SolutionCatalogRequest;

import org.springframework.beans.BeanUtils;
import com.nbsaas.boot.rest.api.Converter;
import com.nbsaas.boot.utils.BeanDataUtils;
            import com.nbsaas.boot.solution.data.entity.SolutionCatalog;
            import com.nbsaas.boot.ad.data.entity.AdPosition;
            import com.nbsaas.boot.ad.data.entity.AdPosition;

/**
* 解决方案分类请求对象转换成实体对象
*/

public class SolutionCatalogEntityConvert  implements Converter<SolutionCatalog, SolutionCatalogRequest> {

    @Override
    public SolutionCatalog convert(SolutionCatalogRequest source) {
        SolutionCatalog result = new SolutionCatalog();
        BeanDataUtils.copyProperties(source, result);
                    if(source.getParent()!=null){
                    SolutionCatalog parent =new SolutionCatalog();
                    parent.setId(source.getParent());
                    result.setParent(parent);
                    }
                    if(source.getMobile()!=null){
                    AdPosition mobile =new AdPosition();
                    mobile.setId(source.getMobile());
                    result.setMobile(mobile);
                    }
                    if(source.getAdPosition()!=null){
                    AdPosition adPosition =new AdPosition();
                    adPosition.setId(source.getAdPosition());
                    result.setAdPosition(adPosition);
                    }
        return result;
    }
}

